-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Standalone functions in PCA #7810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lib/msal-browser/src/interaction_client/BaseInteractionClient.ts
Outdated
Show resolved
Hide resolved
2e779b3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors several methods from the BaseInteractionClient and StandardInteractionClient classes into standalone exported functions to enable better code minification during build output. The refactoring focuses on improving bundle size optimization while maintaining the same functionality.
Key changes:
- Extracted
getRedirectUri
,getDiscoveredAuthority
,initializeServerTelemetryManager
, andclearCacheOnLogout
from BaseInteractionClient as standalone functions - Moved
initializeAuthorizationRequest
from StandardInteractionClient to a standalone function - Created PopupUtils module with
monitorPopupForHash
andcleanPopup
functions extracted from PopupClient - Updated all test files to use the new standalone functions instead of class methods
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/interaction_client/BaseInteractionClient.ts | Converts protected methods to standalone exported functions with proper parameter passing |
src/interaction_client/StandardInteractionClient.ts | Extracts initializeAuthorizationRequest as standalone function and updates calls to use new BaseInteractionClient functions |
src/utils/PopupUtils.ts | New utility file containing popup monitoring and cleanup functions extracted from PopupClient |
src/interaction_client/PopupClient.ts | Removes monitorPopupForHash and cleanPopup methods, updates calls to use PopupUtils functions |
Multiple client files | Updates all interaction clients to use new standalone functions with proper parameter passing |
Multiple test files | Updates test spies and mocks to reference new standalone functions instead of class methods |
change/@azure-msal-browser-*.json | Beachball changefile documenting the patch-level change |
clientConfig?: BrowserConfiguration, | ||
logger?: Logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: these things should be required params. I can't think of a scenario where these would be expected to be undefined
clientId: string, | ||
correlationId: string, | ||
browserStorage: BrowserCacheManager, | ||
logger?: Logger, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should be required
* @returns Promise that resolves to a discovered Authority instance | ||
*/ | ||
export async function getDiscoveredAuthority( | ||
params: { | ||
requestAuthority?: string; | ||
requestAzureCloudOptions?: AzureCloudOptions; | ||
requestExtraQueryParameters?: StringDict; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of scope for this PR but in light of recent conversations around EQP let's consider accepting instanceAware here instead of the whole object and have a separate helper we can use to get the correct value. Can we put something on the backlog?
* @returns Promise that resolves to a discovered Authority instance | ||
*/ | ||
export async function getDiscoveredAuthority( | ||
params: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a good idea to flatten this map as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nits/observations but nothing blocking atm
Turns the following into standalone exported functions to help minify them on build output:
BaseInteractionClient
:getRedirectUri()
getDiscoveredAuthority
initializeServerTelemetryManager()
StandardInteractionClient
:InitializeAuthorizationRequest()
PopupClient
:monitorPopupForHash()
cleanPopup()